#!/bin/bash
# installation minio

. ./public_functions &>/dev/null #公共函数库
. /tmp/public_functions &>/dev/null #公共函数库

logW "下载minio"
logY "curl -# -L --output /home/minio https://dl.min.io/server/minio/release/linux-amd64/minio"
if [[ -f /home/minio ]]; then
   logW "文件已存在"
else
   curl -# -L --output /home/minio https://dl.min.io/server/minio/release/linux-amd64/minio
   checkTF
fi

logW "创建/home/data"
logY ". mkdir /home/data"
rm -rf /home/data
mkdir /home/data
checkTF

#OBlogW ". 解压minio"
#logY "unzip /tmp/minio -d /home"
#yum install unzip -y
#unzip /tmp/minio -d /home
#checkTF

logW ". 给予执行权限"
logY "chmod +x /home/minio"
chmod +x /home/minio
checkTF

logW ". 启动minio"
logY "/home/minio server /home/data &"
/home/minio server /home/data &
checkTF

logW ". 放行9000端口"
  get_Firewalld_status #23#
    if [[ $? -eq 0 ]]; then
      logY "firewall-cmd --zone=public --add-port="9000"/"tcp" --permanent" #1-20#
      firewall-cmd --zone=public --add-port="9000"/"tcp" --permanent 2>/dev/null
      firewall-cmd --reload &>/dev/null
      echo ""
    else
      logR "防火墙未开启" #1-20#
      echo ""
    fi

logW "请访问：http://{ip}:9000"
logW "默认用户名/密码：minioadmin/minioadmin"
echo

